<?php

/*
 * 获得图片上传的完整http路径
 * @param string $str 掉用本方法的当前模块
 * @return string
 */
function ic_getUploadImgFullPath($model,$imgName,$imgCreateTime=false)
{
    $domain=APP_DEBUG?C('img_local_domain'):C('img_cdn_domain');
    //DEBUG   $subPath="localUploads";
    $subPath=APP_DEBUG? "localUploads":'Uploads';
    
    $folder='';
    $subFolder='';
    if($imgCreateTime>0){
        $subFolder="/".ic_dateToStr($imgCreateTime, 'ymd');
    }
    if($model=='bhtype'){
        $folder='bhtype';
    }
    else if($model=='closet'){
        $folder='closet';
    }
    else if($model=='calendar'){
        $folder='calendar';
    }
    else if($model=='commodity'){
        $folder='commodity';
    }
    else if($model=='looks'){
        $folder='looks';
    }
    else if($model=='bhlabel'){
        $folder='bhlabel';
    }
    else if($model=='bhkv'){
        $folder='bhkv';
    }
    else if($model=='test'){
        $folder='test';
    }
    return sprintf("%s/%s/%s%s/%s",$domain,$subPath,$folder,$subFolder,$imgName);
}

/*
 * 获得图片上传的物理路径
 * @param string $str 掉用本方法的当前模块
 * @return string
 */
function ic_getUploadImgServerPath($model,$imgCreateTime=false)
{
    // $domain=APP_DEBUG?C('img_local_domain'):C('img_cdn_domain');
    $domain=$_SERVER['DOCUMENT_ROOT'];
    //DEBUG $subPath="localUploads";
    $subPath=APP_DEBUG? "localUploads":'Uploads';
    
    $folder='';
    $subFolder='';
    if($imgCreateTime>0){
        $subFolder="/".ic_dateToStr($imgCreateTime, 'ymd');
    }
    if($model=='bhtype'){
        $folder='bhtype';
    }
    else if($model=='closet'){
        $folder='closet';
    }
    else if($model=='calendar'){
        $folder='calendar';
    }
    else if($model=='commodity'){
        $folder='commodity';
    }
    else if($model=='looks'){
        $folder='looks';
    }
    else if($model=='bhlabel'){
        $folder='bhlabel';
    }
    else if($model=='test'){
        $folder='test';
    }
    else if($model=='bhkv'){
        $folder='bhkv';
    }
    return sprintf("%s/%s/%s%s/",$domain,$subPath,$folder,$subFolder);
}



/*
 * 对传入字符串做安全过滤,防止sql注入或xss攻击
 * @param string $str 传入字符串
 * @return string
 */
function ic_filterStr($str)
{
    $farr = array(
            "/<(\\/?)(script|i?frame|style|html|body|title|link|meta|object|\\?|\\%)([^>]*?)>/isU",
            "/(<[^>]*)on[a-zA-Z]+\s*=([^>]*>)/isU",
            "/select|insert|update|delete|\'|\/\*|\*|\.\.\/|\.\/|union|into|load_file|outfile|dump/is"
    );
    $str = preg_replace($farr,'',$str);
    return $str;
}
 
/**
 * 过滤接受的参数或者数组,如$_GET,$_POST
 * @param array|string $arr 接受的参数或者数组
 * @return array|string
 */
function ic_filterArr($arr)
{
    if(is_array($arr)){
        foreach($arr as $k => $v){
            $arr[$k] = ic_filterArr($v);
        }
    }else{
        $arr = ic_filterStr($arr);
    }
    return $arr;
}

function ic_isCellPhone($str){
	if(preg_match("/^1[3456789]\d{9}$/", $str)){
		return true;
	}
	return false;
}

/**
 * 判断传入参数是否为正整数
 *
 * @param unknown_type $value
 */
function ic_isPosInt($value){
	if(!is_numeric($value)){
		return false;
	}
	$value=intval($value);
	if($value<=0){
		return false;
	}
    if(stripos($value, '0')===0){
        return false;
    }
	return true;
}

/**
 * 判断传入字符串是否全由数字组成
 *
 * @param unknown_type $str
 * @return unknown
 */
function ic_onlyNumberStr($str){
	$reg="/^\d+$/";
	if (preg_match($reg,$str)){
		return 1;
	}
	else{
		return 0;
	}
}

/**
 * 返回当前月，格式为1506这样
 * @return smallint
 */
function ic_curMonth(){
	return ic_specMonthBefore(0);
}

/**
 * 返回上月，格式为1506这样
 */
function ic_lastMonth(){
	return ic_specMonthBefore(1);
}

/**
 * 返回前月，也即当前月-2月
 */
function ic_theMonthBeforeLastMonth(){
	return ic_specMonthBefore(2);
}

/**
 * @name 返回指定几个月前
 * @param int $c 指定月
 */
function ic_specMonthBefore($c){
	if(!(ic_isPosInt($c)||$c==0)){
		throw new Exception('ic_specMonthBefore参数必须正整数',-1);
	}
	$time=time();
	for($i=0;$i<$c;$i++){
		$time = strtotime('first day of last month',$time);
	}
	return ic_dateToStr($time, 'ym');
}



/**
 * 判断传入值是否 不为空字符串,不空返回true，为空返回false
 * perry add 2012-03-20
 *
 * @param unknown_type $str
 */
function ic_checkUnEmpty($str) {
	// 检测字符串是否为空，是去掉中文空格和英文空格后再验证的
	if (strlen ( $str ) <= 0) {
		return false;
	}
	$nstr = preg_replace ( "/[\s]+/", "", $str );
	$nstr = preg_replace ( "/[\s|　]+/", "", $nstr );
	if (strlen ( $nstr ) > 0) {
		return true;
	} else {
		return false;
	}
}

/**
 * 将时间戳转换为可阅读的字符串格式
 * Author:perry
 * CreateTime:2012-03-15
 *
 * @param unknown_type $timeStamp
 *        	待转换时间戳
 * @param unknown_type $format
 *        	转换格式，默认y-m-d H:i:m
 * @return unknown
 */
function ic_dateToStr($timeStamp, $format = 'y-m-d H:i:m') {
	if (empty ( $timeStamp ) || (null == $timeStamp)) {
		return '';
	}
	$time = date ( $format, $timeStamp );
	return $time;
}

/**
 * 将时间字符串转化成时间戳,如果转化失败返回0
 *
 * @param unknown_type $strDate
 * @return unknown
 */
function ic_strToTimeStamp($strDate) {
	$re = strtotime ( $strDate );
	if (! $re) {
		return 0;
	}
	return $re;
}

/**
 * 检测用户是否登录
 * @return integer 0-未登录，大于0-当前登录用户ID
 * @author harvey
 */
function is_login() {
    $user = session('user_auth');
    if (empty($user)) {
        return 0;
    } else {
        return session('user_auth_sign') == data_auth_sign($user) ? $user['uid'] : 0;
    }
}

/**
 * 数据签名认证
 * @param  array  $data 被认证的数据
 * @return string       签名
 * @author harvey
 */
function data_auth_sign($data) {
    //数据类型检测
    if (!is_array($data)) {
        $data = (array) $data;
    }
    ksort($data); //排序
    $code = http_build_query($data); //url编码并生成query字符串
    $sign = sha1($code); //生成签名
    return $sign;
}

/**
 * 检测验证码
 * @param  integer $id 验证码ID
 * @return boolean     检测结果
 * @author harvey
 */
function check_verify($code, $id = 1) {
    $verify = new \Think\Verify();
    return $verify->check($code, $id);
}


function curlGet($url, $data = NULL) {
	$curl = curl_init();
	curl_setopt($curl, CURLOPT_URL, $url);
	curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
	curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
	if (!empty($data)) {
		curl_setopt($curl, CURLOPT_POST, 1);
		curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
	}
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
	$output = curl_exec($curl);
	#add
	if (curl_errno($curl)) {
		$info = curl_getinfo($curl);
		dump($info);
	}
	#add
	curl_close($curl);
	#add
	$output = json_decode($output, true);
	return $output;
}

/**
 * 判断设备是否为移动端
 */

function ic_isMobile(){
    // 如果有HTTP_X_WAP_PROFILE则一定是移动设备
    if (isset ($_SERVER['HTTP_X_WAP_PROFILE']))
        return true;
 
    //此条摘自TPM智能切换模板引擎，适合TPM开发
    if(isset ($_SERVER['HTTP_CLIENT']) &&'PhoneClient'==$_SERVER['HTTP_CLIENT'])
        return true;
    //如果via信息含有wap则一定是移动设备,部分服务商会屏蔽该信息
    if (isset ($_SERVER['HTTP_VIA']))
        //找不到为flase,否则为true
        return stristr($_SERVER['HTTP_VIA'], 'wap') ? true : false;
    //判断手机发送的客户端标志,兼容性有待提高
    if (isset ($_SERVER['HTTP_USER_AGENT'])) {
        $clientkeywords = array(
            'nokia','sony','ericsson','mot','samsung','htc','sgh','lg','sharp','sie-','philips','panasonic','alcatel','lenovo','iphone','ipod','blackberry','meizu','android','netfront','symbian','ucweb','windowsce','palm','operamini','operamobi','openwave','nexusone','cldc','midp','wap','mobile'
        );
        //从HTTP_USER_AGENT中查找手机浏览器的关键字
        if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower($_SERVER['HTTP_USER_AGENT']))) {
            return true;
        }
    }
    //协议法，因为有可能不准确，放到最后判断
    if (isset ($_SERVER['HTTP_ACCEPT'])) {
        // 如果只支持wml并且不支持html那一定是移动设备
        // 如果支持wml和html但是wml在html之前则是移动设备
        if ((strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') !== false) && (strpos($_SERVER['HTTP_ACCEPT'], 'text/html') === false || (strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') < strpos($_SERVER['HTTP_ACCEPT'], 'text/html')))) {
            return true;
        }
    }
    return false;
}

function ic_check_ip_format($ip) {
        if (!preg_match("/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/", $ip)) {
            return false;
        }
        $ipa = explode('.', $ip);
        $len = count($ipa);
        $zcount = 0;
        $mcount = 0;
        for ($i = 0; $i < $len; $i++) {
            if ($ipa[$i] > 255 || $ipa[$i] < 0) {
                return false;
            }
            if ($ipa[$i] == 0) {
                $zcount++;
            } elseif ($ipa[$i] == 255) {
                $mcount++;
            }
        }
        if ($zcount == 4 || $mcount == 4) {
            return false;
        }
        return true;
    }

  /**
     * @name 将数组key去掉
     * @author  perry
     * @version  1.0 2015/9/21
     * @param unknown_type $arr
     * @param unknown_type $split
     */
	 function ic_getArrayValuesArray($arr, $subKey = false) {
        $re = false;
        foreach ($arr as $key => $val) {
            if ($subKey) {
                if (is_array($val)) {
                    $re[] = $val[$subKey];
                } else {
                    $re[] = $val->$subKey;
                }
            } else {
                $re[] = $val;
            }
        }

        return $re;
    }


    /**
     * @name 安全的根据数组key返回value，如果下标越界或键名称不存在，返回null
     * tips:最多支持2维数组
     * @param int $c 指定月
     */
     function ic_get_safe_arr_val($key, $arr, $sub_key = false, $default_return_val = null) {
        if (is_array($arr) || method_exists($arr, 'toArray')) {
            if (!is_array($arr)) {
                $arr = $arr->toArray();
            }
            if (array_key_exists($key, $arr)) {
                if ($sub_key) {
                    return ic_get_safe_arr_val($sub_key, $arr[$key]);
                }
                return $arr[$key];
            }
            return $default_return_val;
        }
        return $default_return_val;
    }


    /**
     * 将指定秒转换成xx天xx小时xx分格式
     * @author zhuyanhua 2016-01-07
     * @return string
     */
 function convert_seconds($sec){
        $re='';
        if($sec>86400){
            $re=$re.(floor($sec/86400))."天";
            $sec = $sec % 86400;
        }
        if($sec>3600){
            $re=$re.(floor($sec/3600))."小时";
            $sec = $sec % 3600;
        }
        if($sec>60){
            $re=$re.(floor($sec/60))."分";
            $sec = $sec % 60;
        }
        if($re==''){
            $re=$sec."秒";
        }
        return $re;

    }


    /**
* @邮箱
*/
function ic_isEmail($subject) {
$pattern='/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/';
if(preg_match($pattern, $subject)){
return true;
}
return false;
}


/**
* @name 判断是否是微信端访问
* @return boolean
*/
function ic_isWeixin() {
	if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'micromessenger') !== FALSE) {
		return true;
	} else {
		return false;
	}
}

/**
 * @author Tujt 2015-11-16
 */
function timeToDate($time,$type='Y-m-d') {
    if(empty($time)) return '';
	return date($type,$time);
}
/**
 * @author Tujt 2015-11-23
 */
function WeixinSex($wx_sex) {
	$sex = '';
    switch($wx_sex){
        case '1':
            $sex = '男';
            break;
        case '2':
            $sex = '女';
            break;
		default:
			$sex = '未知';
    }
	return $sex;
}

  function ic_get_auth(){
    $cache=session('ic_get_auth_re');
    if($cache){
        return $cache;
    }

    $id = session('uid');

    $user=D('Admin/AuthGroupaccess');

    $group_id=$user->user($id);

    $auth_group=D('Admin/AuthGroup');

    $ff=$auth_group->group($group_id);

    $dfdf=array();

    foreach($ff as $k=>$value){

        $gg=explode(',',$ff[$k]['rules']);

        foreach($gg as $v=>$va){
            if(!in_array($va,$dfdf)){
                array_push($dfdf,$va);
            }
        }
    }
    $auth_rule= D('Admin/Authrule');

    $name=$auth_rule->rlue($dfdf);
    session('ic_get_auth_re',$name);
    return $name;

    }

    function ic_has_auth($mcf=false){

        $id = session('uid');
        if($id==1){
            //admin有全部权限
            return true;
        }

        $name=ic_get_auth();

        $ghh=false;//设定默认值
        if(!$mcf){
            $mcf=MODULE_NAME."/".CONTROLLER_NAME."/".ACTION_NAME;
        }
        foreach($name as $ks=>$bb){
            if(strtolower($mcf)==strtolower($bb['name'])){
                $ghh=true;
                break;
            }
        }
        // if(!$ghh){
        //     $this->error('您没有权限访问此页面,请联系管理员', __APP__ . '/Admin/Clerk/index');
        // }
        return $ghh;
    }

    function ic_has_auth_todisplay($mcf=false,$args=false){
        if(ic_has_auth($mcf)){
            return 'inline';
        }
        return 'none';
    }

    function xmlToArray($xml) {
        return $xml ? xmlToArrayElement(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)) : array();
    }

    function xmlToArrayElement($xmlobject) {
        $data = array();
        foreach ((array) $xmlobject as $key => $value) {
            $data[$key] = !is_string($value) ? xmlToArrayElement($value) : $value;
        }
        return $data;
    }

    function ic_micro_time(){
        list($t1, $t2) = explode(' ', microtime());
        return (float)sprintf('%.0f',(floatval($t1)+floatval($t2))*1000);
    }

    /**
     *+----------------------------------------------------------
     * 产生随机字串，可用来自动生成密码
     * 默认长度6位 字母和数字混合 支持中文
     *+----------------------------------------------------------
     * @param string $len 长度
     * @param string $type 字串类型
     * 0 字母 1 数字 其它 混合
     * @param string $addChars 额外字符
     *+----------------------------------------------------------
     * @return string
     *+----------------------------------------------------------
     */
    function ic_randString($len=6,$type='',$addChars='') {
        $str ='';
        switch($type) {
            case 0:
                $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.$addChars;
                break;
            case 1:
                $chars= str_repeat('0123456789',3);
                break;
            case 2:
                $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ'.$addChars;
                break;
            case 3:
                $chars='abcdefghijklmnopqrstuvwxyz'.$addChars;
                break;
            case 4:
                $chars = "们以我到他会作时要动国产的一是工就年阶义发成部民可出能方进在了不和有大这主中人上为来分生对于学下级地个用同行面说种过命度革而多子后自社加小机也经力线本电高量长党得实家定深法表着水理化争现所二起政三好十战无农使性前等反体合斗路图把结第里正新开论之物从当两些还天资事队批点育重其思与间内去因件日利相由压员气业代全组数果期导平各基或月毛然如应形想制心样干都向变关问比展那它最及外没看治提五解系林者米群头意只明四道马认次文通但条较克又公孔领军流入接席位情运器并飞原油放立题质指建区验活众很教决特此常石强极土少已根共直团统式转别造切九你取西持总料连任志观调七么山程百报更见必真保热委手改管处己将修支识病象几先老光专什六型具示复安带每东增则完风回南广劳轮科北打积车计给节做务被整联步类集号列温装即毫知轴研单色坚据速防史拉世设达尔场织历花受求传口断况采精金界品判参层止边清至万确究书术状厂须离再目海交权且儿青才证低越际八试规斯近注办布门铁需走议县兵固除般引齿千胜细影济白格效置推空配刀叶率述今选养德话查差半敌始片施响收华觉备名红续均药标记难存测士身紧液派准斤角降维板许破述技消底床田势端感往神便贺村构照容非搞亚磨族火段算适讲按值美态黄易彪服早班麦削信排台声该击素张密害侯草何树肥继右属市严径螺检左页抗苏显苦英快称坏移约巴材省黑武培著河帝仅针怎植京助升王眼她抓含苗副杂普谈围食射源例致酸旧却充足短划剂宣环落首尺波承粉践府鱼随考刻靠够满夫失包住促枝局菌杆周护岩师举曲春元超负砂封换太模贫减阳扬江析亩木言球朝医校古呢稻宋听唯输滑站另卫字鼓刚写刘微略范供阿块某功套友限项余倒卷创律雨让骨远帮初皮播优占死毒圈伟季训控激找叫云互跟裂粮粒母练塞钢顶策双留误础吸阻故寸盾晚丝女散焊功株亲院冷彻弹错散商视艺灭版烈零室轻血倍缺厘泵察绝富城冲喷壤简否柱李望盘磁雄似困巩益洲脱投送奴侧润盖挥距触星松送获兴独官混纪依未突架宽冬章湿偏纹吃执阀矿寨责熟稳夺硬价努翻奇甲预职评读背协损棉侵灰虽矛厚罗泥辟告卵箱掌氧恩爱停曾溶营终纲孟钱待尽俄缩沙退陈讨奋械载胞幼哪剥迫旋征槽倒握担仍呀鲜吧卡粗介钻逐弱脚怕盐末阴丰雾冠丙街莱贝辐肠付吉渗瑞惊顿挤秒悬姆烂森糖圣凹陶词迟蚕亿矩康遵牧遭幅园腔订香肉弟屋敏恢忘编印蜂急拿扩伤飞露核缘游振操央伍域甚迅辉异序免纸夜乡久隶缸夹念兰映沟乙吗儒杀汽磷艰晶插埃燃欢铁补咱芽永瓦倾阵碳演威附牙芽永瓦斜灌欧献顺猪洋腐请透司危括脉宜笑若尾束壮暴企菜穗楚汉愈绿拖牛份染既秋遍锻玉夏疗尖殖井费州访吹荣铜沿替滚客召旱悟刺脑措贯藏敢令隙炉壳硫煤迎铸粘探临薄旬善福纵择礼愿伏残雷延烟句纯渐耕跑泽慢栽鲁赤繁境潮横掉锥希池败船假亮谓托伙哲怀割摆贡呈劲财仪沉炼麻罪祖息车穿货销齐鼠抽画饲龙库守筑房歌寒喜哥洗蚀废纳腹乎录镜妇恶脂庄擦险赞钟摇典柄辩竹谷卖乱虚桥奥伯赶垂途额壁网截野遗静谋弄挂课镇妄盛耐援扎虑键归符庆聚绕摩忙舞遇索顾胶羊湖钉仁音迹碎伸灯避泛亡答勇频皇柳哈揭甘诺概宪浓岛袭谁洪谢炮浇斑讯懂灵蛋闭孩释乳巨徒私银伊景坦累匀霉杜乐勒隔弯绩招绍胡呼痛峰零柴簧午跳居尚丁秦稍追梁折耗碱殊岗挖氏刃剧堆赫荷胸衡勤膜篇登驻案刊秧缓凸役剪川雪链渔啦脸户洛孢勃盟买杨宗焦赛旗滤硅炭股坐蒸凝竟陷枪黎救冒暗洞犯筒您宋弧爆谬涂味津臂障褐陆啊健尊豆拔莫抵桑坡缝警挑污冰柬嘴啥饭塑寄赵喊垫丹渡耳刨虎笔稀昆浪萨茶滴浅拥穴覆伦娘吨浸袖珠雌妈紫戏塔锤震岁貌洁剖牢锋疑霸闪埔猛诉刷狠忽灾闹乔唐漏闻沈熔氯荒茎男凡抢像浆旁玻亦忠唱蒙予纷捕锁尤乘乌智淡允叛畜俘摸锈扫毕璃宝芯爷鉴秘净蒋钙肩腾枯抛轨堂拌爸循诱祝励肯酒绳穷塘燥泡袋朗喂铝软渠颗惯贸粪综墙趋彼届墨碍启逆卸航衣孙龄岭骗休借".$addChars;
                break;
            default :
                // 默认去掉了容易混淆的字符oOLl和数字01，要添加请使用addChars参数
                $chars='ABCDEFGHIJKMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789'.$addChars;
                break;
        }
        if($len>10 ) {//位数过长重复字符串一定次数
            $chars= $type==1? str_repeat($chars,$len) : str_repeat($chars,5);
        }
        if($type!=4) {
            $chars   =   str_shuffle($chars);
            $str     =   substr($chars,0,$len);
        }else{
            // 中文随机字
            for($i=0;$i<$len;$i++){
              $str.= self::msubstr($chars, floor(mt_rand(0,mb_strlen($chars,'utf-8')-1)),1);
            }
        }
        return $str;
    }

    //将HTTP_REFERER记录到session
    function ic_rememberFormerPage(){
        $_SESSION['from_index_url'] =  $_SERVER['HTTP_REFERER'];
    }

    function ic_backToFormerPage($default){
        if(array_key_exists('from_index_url', $_SESSION)){
            $rurl=$_SESSION['from_index_url'];
            unset($_SESSION['from_index_url']);
        }
        else {
            // $rurl= __CONTROLLER__ . '/index';
            $rurl= $default;
        }
        return $rurl;
    }

    function ic_getThumbImg($imgUrl,$type){
        $tmpArr=explode('/', $imgUrl);
        $len=count($tmpArr);
        if($len>0){
            $tmpArr[$len-1]=$type.$tmpArr[$len-1];
        }
        return implode("/", $tmpArr);
    }

    //获取客户端提交的上传文件并存入到指定位置
    function ic_uploadFile($allowExts="xls,xlsx",$subFolder="commodity",$ispic=false){
        //导入上传类
        $upload = new \Admin\ORG\UploadFileNew();
        //设置上传文件大小
        $upload->maxSize            = 100*1024*1024;
        //设置上传文件类型
        $upload->allowExts          = explode(',', $allowExts);
        //设置附件上传目录
        $upload->savePath           = ic_getUploadImgServerPath($subFolder,false);
        //设置需要生成缩略图，仅对图像文件有效
        $upload->thumb              = $ispic;
        // 设置引用图片类库包路径
        $upload->imageClassPath     = 'Think.ImageNew';
        //设置需要生成缩略图的文件后缀
        $upload->thumbPrefix        = 'm_,s_';  //生产2张缩略图
        //设置缩略图最大宽度
        $upload->thumbMaxWidth      = '700,200';
        //设置缩略图最大高度
        $upload->thumbMaxHeight     = '850,243';
        //设置上传文件规则
        $upload->saveRule           = 'uniqid';
        //删除原图
        $upload->thumbRemoveOrigin  = false;
        if (!$upload->upload()) {
            //捕获上传异常
            throw new \Exception($upload->getErrorMsg(), -811);
            
        } else {
            //取得成功上传的文件信息
            $uploadList = $upload->getUploadFileInfo();
            return $uploadList;
        }
    }

      /***
     * @name 读取EXCEL表格转变成数组数据返回
    * @access private
    * @param $uploadfile 要读取的Excel表格文件路径
    * @return $arr array从excel表格读取的数组返回
    */
    function ic_importFromExcel($uploadfile,$startRow=2,$startCol="A",$endCol="M") {
        vendor("phpexcel.PHPExcel");
        try {
            $objReader = PHPExcel_IOFactory::createReader('Excel2007');
            $objReader->setReadDataOnly(true);
            $objWorkBook = @$objReader->load($uploadfile);
            $objWorksheet = $objWorkBook->getActiveSheet();
            $highestRow = $objWorksheet->getHighestRow(); // 取得总行数
            $highestColumn = $objWorksheet->getHighestColumn(); // 取得总列数
            //echo "行数：$highestRow 列数：$highestColumn";die;
            $arr = array(); //最终导出数据源
            for ($i = $startRow; $i <= $highestRow; $i++) {
                if(strtolower(trim($objWorksheet->getCell('C' . $i)->getValue()))=='end'){
                    break;
                }
                $arr_temp = array();
                for ($j = $startCol; $j <= $endCol; $j++) {
                    $arr_temp[] = trim($objWorksheet->getCell($j . $i)->getValue());
                    
                }
                $arr[] = $arr_temp;
            }
            
            //          echo $arr;die;
            return $arr; //最终数据源
        } catch (\Exception $a) {
            return $a->getMessage();
        }
    }

    function ic_getDiffSizeImg($oriImgName, $sizeType){
        if($sizeType=='thumb'){
            return "s_".$oriImgName;
        }
        if($sizeType=='medium'){
            return "m_".$oriImgName;
        }
        return $oriImgName;
    }

